Blog

Luis Majano

April 15, 2009

Spread the word


Share your thoughts

When using ColdBox's SES routing mechanisms you will come to a point where you would like to create variables depending on when a specific route matches or not.  You can do so very easily by using the argument called matchVariables, which is a simple string of name-value pairs you want to create in the request collection (This was added in version 2.6.3).  However, a hidden feature that we just documented that has been enabled since version 2.6.0, is that you can also pass named arguments to the addCourse() method and have them created on the request collection when the route matches.  This makes it much much easier to create simple or complex variables than a simple string of name-value pairs.

Example using matchVariables:

That route will create the spaceUsed,foundAt variables in the request collection when the route matches. However, let's see how easy it is to do it using by convention name-value pairs in the method. I just added the foundAt,internalNamespace, and HashMap variables just by adding them as virtual arguments. It gets even better if you are running Railo because you can use implicit Array/Structure notation to create very complex variables. Again, this is now a documented feature in the wiki, so enjoy.

Add Your Comment

(1)

Apr 16, 2009 06:49:34 UTC

by Anuj Gakhar

Thanks for documenting this. Took me a while to figure this out. I blogged as well about this. http://www.anujgakhar.com/2009/04/15/a-small-coldbox-tip/

Recent Entries

Into the Box is Going Online, Register Now!

Into the Box is Going Online, Register Now!

Dive into the Future of Web Development with Into the Box 2024 - now going global and online! No matter where you are, you're invited to join us for an amazing and enriching two-day experience on May 16th and 17th, packed with groundbreaking insights, expert sessions, and game-changing announcements.

Maria Jose Herrera
Maria Jose Herrera
May 01, 2024
Into the Box 2024: Your Gateway to the Future of Tech!

Into the Box 2024: Your Gateway to the Future of Tech!

Are you ready to advance your coding skills? The future of Modern Web Development awaits at Into the Box 2024, and we're thrilled to announce that due to high demand, we're extending our Early Bird pricing for an additional week!

Maria Jose Herrera
Maria Jose Herrera
April 26, 2024